<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>H+ 后台主题UI框架 - 空白页</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
     <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">
     <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
    <!-- jqgrid-->
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">

     <link rel="stylesheet" href="__STATIC__/layout/css/channel.css" type="text/css">
    
    <style>
        .radio-inline input[type=radio] {
            margin-top: 4px
        }
    </style>
</head>

<body style="color:#333;padding:3px;" class="x_sorll" >
    <!-- 标题 -->
    <div class="page-heade">
        <h1 class="title_color">常规促销申请明细</h1>
    </div>
    <!-- 标题 -->
    <form class="form-inline" id="zhuapply">
        <table class="table-bordered table text-left" border="1">
            <tr>
                <td><label for="" class="form-label">主题<span class="colorRed">*</span>：</label></td>
                <td><input type="text" class="form-control" name="theme" id="theme" value="{if condition="$aid neq 0"}{$apply.title}{/if}"></td>
            </tr>
            <tr>
                 <td style="min-width: 180px;width: 180px"><label for="">经销商<span class="
            colorRed">*</span>：</label></td>
                <td colspan="5">
                    <div class="col-xs-4">
                        <div class="input-group" id="jxs_input" {if condition="$aid neq 0"}style="display:none;"{/if}>
                            <input type="text"   placeholder="请输入关键字或空格查询" class="form-control inputremindPeple" id="remainMan" name="jxs_id" value="{if condition="$aid neq 0"}{$apply.jxs_id}{/if}">
                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
                                    <span class="caret"></span>
                                </button>
                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
                                </ul>
                            </div>
                        </div>
                        <div id="jxs_queding" class="selectedOnlyOne" {if condition="$aid eq 0"}style="display:none;"{/if} >
                            <span class="inin">{if condition="$aid neq 0"}{$apply.jxs}{/if}</span>
                            <span class="close">×</span>
                        </div>
                    </div>
                    <div class="col-xs-2">
                        <input type="button" class="btn btn-primary btn-sm" id="select" value="选择"/>
                    </div>
                </td>
            </tr>
            <tr style="display: none">
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            </tr>
            <tr>
                <td><label for="" class="form-label">归档提醒：</label></td>
                <td>
                      <label>
                         <input type="checkbox" name="is_notice" {if condition="$aid eq 0"}checked{else/}{if condition="$apply.is_notice eq 1"}checked{/if}{/if}>(温馨提示：若设置归档提醒，则该申请归档后系统会自动发送邮件及弹框提醒您。)
                     </label>
                </td>
            </tr>
        </table>
      <div class="contact-box">

            <input type="button" value="添加数据" class="btn btn-success btn-sm" aid="{$aid}" id="addData"/>
            (至少添加一条费用明细) <span class="colorRed">温馨提示：1）一个活动不要分开申请，否则会影响该活动的ROI;2)多个活动不要放在同一个申请中申请，否则会影响后续的反馈，核销。谢谢！</span>
      </div>
    
    <div class="row no-padding">
        <table class="table row-margin-top table-bordered text-center bud_hei">
        <tr class="info">
            <td style="min-width: 240px;width: 240px" colspan="2" rowspan="2">
                 <input type="button" class="btn btn-info btn-sm qx" value="全选"/>
               <input type="button" class="btn btn-info btn-sm fx" value="反选"/>
               <input type="button" class="btn btn-info btn-sm plsc" value="批量删除"/>
            </td>
            <td rowspan="2">No.</td>
            <td rowspan="2">明细编号</td>
            <td rowspan="2">系统名称</td>
            <td rowspan="2">负责人</td>
            <td rowspan="2">网点名称</td>
            <td rowspan="2">产品系列</td>
            <td>促销产品</td>
            <td rowspan="2">促销执行时间</td>
            <td rowspan="2">预计核销时间</td>
            <td colspan="2">预计销售量</td>
            <td rowspan="2">需补差销售量</td>
            <td colspan="12">折价幅度</td>
            <td colspan="7">三级费用科目</td>
            <td rowspan="2">费用支付方式</td>
            <td rowspan="2">费用小计</td>
            <td rowspan="2">预计费用率</td>
            <td rowspan="2">基准销量</td>
            <td rowspan="2">预计ROI</td>
            <td rowspan="2">备注</td>
            <td rowspan="2">费用计入部门</td>
            <td rowspan="2">费用计入方案</td>
        </tr>
         <tr class="info">
            <td>单品</td>
            <td>数量</td>
            <td>销售额</td>
            <td>标准出厂价</td>
            <td>经销商原供货价</td>
            <td>经销商现供货价</td>
            <td>经销商折价幅度</td>
            <td>经销商总折价金额(元)</td>
            <td>经销商毛利率</td>
            <td>网点正常供货价</td>
         
            <td>网点促销供货价</td>
            <td>网点折价幅度</td>
            <td>网点总折价金额(元)</td>
            <td>原零售价</td>
            <td>活动期零售价</td>
            <td>费用名称</td>
            <td>未税费用金额(元)</td>
            <td>是否增值税(可抵扣)</td>
            <td>税率</td>
            <td>含税费用金额(元)</td>
            <td>实际投入费用(元)</td>
            <td>费用描述</td>
        </tr>
        {if condition="$aid neq 0"}
            {volist name="applynet" id="vo"}
                {volist name="applyde" id="vo1" key="j"}
                    {if condition="$vo.net_id eq $vo1.net_id"}
                        <tr>
                            <td><input type="checkbox" value="{$vo1.did}" class="ckde"/> </td>
                            <td>
                                <input type="button" class="btn btn-info btn-sm" value="修改" onclick="xiugai({$vo1.did})"/>
                                 <input type="button" class="btn btn-danger btn-sm" value="删除本条" onclick="shanchu({$vo1.did})"/>
                            </td>
                            <td>
                                {$j}
                                {if condition="$vo1.is_bu eq 1"}<span style="color:red;border:1px solid red;">补单</span>{/if}
                            </td>
                            <td>
                                <a href="{:url('dataview')}?did={$vo1.did}" class="J_menuItem" title="{$vo1.no}"> {$vo1.no}-{$vo1.detail_no}</a><a href="{:url('Commonti/decisionb')}?did={$vo1.did}"  class="J_menuItem"><span style="display: none;">决策信息</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a>
                            </td>
                            <td>{$vo1.xitong}</td><td>{$vo1.fuzeren}</td><td>{$vo1.net}<a href="{:url('Commonti/netyj')}?did={$vo1.did}" class="J_menuItem"><span style="display: none;">网点决策依据</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
                            <td>{$vo1.series_name}<a href="{:url('Commonti/seriosroi')}?did={$vo1.did}" class="J_menuItem"><span style="display: none;">ROI决策信息</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
                            <td>{$vo1.pro_name}<a href="{:url('Commonti/productroi')}?did={$vo1.did}" class="J_menuItem"><span style="display: none;">ROI决策信息</span><span class="glyphicon glyphicon-zoom-in fangda" aria-hidden="true" style="display: inline-block;"></span></a></td>
                            <td>{$vo1.start_time}<br/>{$vo1.end_time}</td><td>{$vo1.hexiao_time}</td>
                            <td><span class="num2">{$vo1.sell_num}</span>箱</td><td><span class="num2">{$vo1.xiaoshoue}</span></td><td>{if condition="$vo1.bucha neq ''"}<span class="num2">{$vo1.bucha}</span>箱{/if}</td>
                            <td><span class="num2">{$vo1.factory}</span>元/{$vo1.unit}</td>
                            <td><span class="num2">{$vo1.yuan_price}</span>元/{$vo1.unit}</td>
                            <td><span class="num2">{$vo1.now_price}</span>元/{$vo1.unit}</td>
                            <td>{$vo1.zhejia}%</td><td class="num2">{$vo1.jxscha}</td><td><span class="num2">{$vo1.maoli}</span>%</td><td><span class="num2">{$vo1.wangdian_yuan}</span>元/{$vo1.unit}</td>
                            <td {if $vo1.netout==1} style="background: red;" {/if}><span class="num2" >{$vo1.wangdian_price}</span>元/{$vo1.unit}</td><td><span class="num2">{$vo1.wangdian_zhejia}</span>%</td><td class="num2">{$vo1.netcha}</td>
                            <td><span class="num2">{$vo1.lingshou_price}</span>元/{$vo1.unit}</td><td {if $vo1.huodongout==1} style="background: red;" {/if}><span class="num2" >{$vo1.huodong_price}</span>元/{$vo1.unit}</td><td>{$vo1.feiyong3}</td>
                            <td><span class="num2">{$vo1.zonge}></span></td><td>{if condition="$vo1.dikou eq 1"}可{else/}否{/if}</td><td>{$vo1.shuilv}%</td><td><span class="num2">{$vo1.hanshui}</span></td><td><span class="num2">{$vo1.hanshui}</span></td><td>{$vo1.remark}</td><td>{$vo1.zffs}</td><td><span class="num2">{$vo1.hanshui}</span></td>
                            <td>{$vo1.yujifeiyonglv}%</td><td>{$vo1.jizhunboxnum}</td><td>{$vo1.yujiroi}%</td><td>{$vo1.beizhu}</td><td>{$vo1.de_name}</td><td>{$vo1.jrfa}</td>
                        </tr>
                        
                    {/if}
                {/volist}
        

                <tr>
                    <td colspan="2"></td> <td colspan="5" class="text-right">小计</td>
                    <td></td><td></td><td></td><td></td>
                    <td><span class="num2">{$vo.sellnums}</span></td><td><span class="num2">{$vo.xiaoshoues}</span></td><td><span class="num2">{$vo.buchas}</span></td>
                    <td></td><td></td><td></td><td></td><td class="num2">{$vo.jxscha}</td><td></td><td></td><td></td><td></td><td class="num2">{$vo.netcha}</td><td></td><td></td><td></td>
                    <td><span class="num2">{$vo.zonges}</span></td><td></td><td></td>
                    <td><span class="num2">{$vo.hanshuis}</span></td><td><span class="num2">{$vo.hanshuis}</span></td><td></td><td></td>
                    <td><span class="num2">{$vo.hanshuis}</span></td><td><span class="num2">{$vo.feiyonglv}</span>%</td><td></td><td><span class="num2">{$vo.yujirois}</span>%</td>
                    <td></td><td></td><td></td>
                </tr>
            {/volist}
        {/if}
         <tr class="trTotal">
           <td style="min-width: 240px;width: 240px" colspan="2">
                <input type="button" class="btn btn-info btn-sm qx" value="全选"/>
                 <input type="button" class="btn btn-info btn-sm fx" value="反选"/>
                <input type="button" class="btn btn-info btn-sm plsc" value="批量删除"/>
            </td>
            <td colspan="5" class="text-right">合计</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right font-bold"><span class="num2">{$all.sellnums}</span></td>
            <td class="text-right font-bold"><span class="num2">{$all.xiaoshoues}</span></td>
           <td class="text-right font-bold"><span class="num2">{$all.buchas}</span></td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
             <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right"><span class="num2">{$all.jxscha}</span></td>
             <td>&nbsp;</td>
            <td>&nbsp;</td>
             <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right"><span class="num2">{$all.netcha}</span></td>
              <td>&nbsp;</td>
             <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right"><span class="num2">{$all.zonges}</span></td>
              <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right"><span class="num2">{$all.hanshuis}</span></td>
            <td class="text-right"><span class="num2">{$all.hanshuis}</span></td>
              <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td class="text-right"><span class="num2">{$all.hanshuis}</span></td>
            <td><span class="num2">{$all.feiyonglv}</span>%</td>
            <td>&nbsp;</td>
            <td><span class="num2">{$all.yujirois}</span>%</td>
            <td colspan="3">&nbsp;</td>
        </tr>
        </table>
         {if condition="$aid neq 0"}
          {if $apply.status==2}
          <div class="" style="margin:20px 10px 20px 20px;">
         <table class="table table-bordered text-left bud_hei">
            <tr class="info">
                <th class="text-left font-bold">审批意见</th>
            </tr>
            {volist name="logs" id="l"}
          <tr>
              <td>{$l.USERNAME} 审批动作：{$l.MEMO}；审批意见：{if $l.COMMENTS}{$l.COMMENTS}{else/}无{/if}(审批时间：{$l.ACTIONTIME})</td>
          </tr>
          
          {/volist}
      </table>
      </div>
      {/if}{/if}
        <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
            <div id="uploader" class="wu-example">
                <!--用来存放文件信息-->
                <div id="thelist" class="uploader-list">
                   {volist name="fujian" id="fo"}
                        <h4>{$fo.file_name}</h4>
                   {/volist}
                </div>
                <div class="btns">
                    <div id="picker">选择文件</div>
                    <button id="ctlBtn" class="btn btn-sm btn-default">开始上传</button>
                </div>
                <input type="hidden" name="attach" id="attach" {if condition="$aid neq 0"} value="{$apply.annex_id}" {/if} >
            </div>
            <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
        </div>

      <div class="row text-center no-padding">
            {if condition="$aid eq 0"}
                <input type="button" class="btn btn-primary" onclick="tijiao(1)" value="保存为草稿"/>
                <input type="button" class="btn btn-warning" onclick="tijiao(3)" value="保存并提交流程"/>
            {else/}
                {if $apply.status==2}
                <input type="hidden" name="aid" value="{$aid}"/>
                 <input type="hidden" id="nodeKey" name="nodeKey"/>
                  <input type="hidden" id="selectId" name="selectId"/>
                  <input type="hidden" id="selectName" name="selectName"/>
                    {volist name="btn.nextNodes" id="b"}
                      {if $b.nodeName=='结束'}
                      <input type="button" class="btn-danger btn" onclick="zuofei('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="点此作废"/>
                      {else/}
                      <input type="button" class="btn-info btn" onclick="baocun('{$b.nodeKey}','{$b.selectId}','{$b.selectName}')" value="保存并提交工作流"/>
                      {/if}
                    {/volist}
                {else/}
            <input type="button" class="btn btn-primary" onclick="tijiao(1)" value="保存为草稿"/>
            <input type="button" class="btn btn-warning" onclick="tijiao(3)" value="保存并提交流程"/>
            
            {/if}{/if}
            <button  class="btn btn-info" type="button" onclick="back()">返回</button>
      </div>

    </div>
     </form>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
    <script>
     var fr={$from};
      function baocun(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('baocunchuli')}",
          data:$('#zhuapply').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
            //alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                  if(fr==1)
                                        location.href="{:url('index')}"
                                  else
                                        location.href="{:url('Workflowdb/index')}"
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }           
          }
        });
}
     function zuofei(nodeKey,selectId,selectName){
  $("#nodeKey").val(nodeKey)
  $("#selectId").val(selectId)
  $("#selectName").val(selectName)
   $.ajax({
          cache: true,
          type: "POST",
          url:"{:url('zuofeichuli')}",
          data:$('#zhuapply').serialize(),// 你的formid
          async: false,
          error: function(request) {
            alert("Connection error");
          },
          success: function(data) {
           // alert(data);
            //var res=JSON.parse(data);
                    var res1=JSON.parse(data);
                            if(res1["state"]==1){
                              swal({
                                title: "完成",
                                text: "操作已成功",
                                type: "success"
                                },function(){
                                   if(fr==1)
                                        location.href="{:url('index')}"
                                    else
                                        location.href="{:url('Workflowdb/index')}"
                                  //parent.layer.close(parent.layer.getFrameIndex(window.name))
                                  //
                                });

                          }else{
                            swal({
                            title: "错误",
                            text:  res1["msg"],
                            type: "warning"
                            });
                          }         
          }
        });
}
    function tijiao(state){
         var num=0;
         var aid={$aid};
         var is_notice=0;
        $(".ckde").each(function(){
            num++;
        })
        var msg="";
        if($("#theme").val()==""){
            msg="主题不能为空";
        }else if($("#remainMan").val()==""){
            msg="经销商必须选择";
        }
        else if(num==0){
            msg="至少一条明细";
        }
        if(msg==""){
            if($("input[name='is_notice']").prop("checked")){
                is_notice=1;
            }
            $.post("{:url('TiApply/baocunapply')}",{aid:aid,jxs:$("#remainMan").val(),is_notice:is_notice,fujian:$("#attach").val(),state:state,title:$("#theme").val()},function(re){
                //alert(re);
                 var res=JSON.parse(re);
                                    if(res["state"]==1){
                                        swal({
                                        title: "完成",
                                        text: "操作已成功",
                                        type: "success"
                                        },function(){
                                           location.href="{:url('TiApply/index')}";
                                        });
                                    }else{
                                          swal({
                                             title: "错误",
                                             text: res["msg"],
                                             type: "warning"
                                         });
                                    }
            })
        }else{
            swal({
                    title: "错误",
                    text:  msg,
                    type: "warning"
                    });
        }
    }
    function back(){
        if(fr==1)
            location.href="{:url('TiApply/index')}";
        else
            location.href="{:url('Workflowdb/index')}"
    }
       
        $(document).ready(function(){
             $(".num2").each(function(){
        if(!isNaN(parseFloat($(this).html())))
         var num=parseFloat($(this).html()).toFixed(2);
        else
            var num="0.00";
        $(this).html(num);
    })
		       $("#addData").click(function () {

		            if ($("#title").val() == "") {
		                sweetAlert("", "主题不能为空！", "error");
		            } else if ($("#remainMan").val() == "") {
		                sweetAlert("", "经销商不能为空！", "error");
		            } else {
		                var jxs = $('#remainMan').val() //经销商
		              // alert(jxs);
		                var index = layer.open({
		                    type:2,
		                    title:'添加数据',
		                    area:['80%','80%'],
		                    maxmin:true,
		                    content:'{:url("addData")}?jxs='+jxs+'&aid='+$(this).attr("aid")
		                })
		                layer.full(index)
		            }
		        })


             $("#remainMan").bsSuggest({
            url: "{:url('select/myjxsjson')}",
            /*effectiveFields: ["userName", "shortAccount"],
             searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias:{title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
            $('#jxs_queding').find('.inin').html(keyword.key)
            $('#jxs_queding').show()
            $('#jxs_input').hide()
            $('#jxs_input').find('input').val(keyword.id)
            //console.log('onSetSelectValue: ', keyword, data);


            $("#remainMan2").bsSuggest('destroy')
            var catbs = $("#remainMan2").bsSuggest({
                url: "{:url('select/netjson')}?keyword="+keyword.id,
                effectiveFieldsAlias:{title: "名称"},
                ignorecase: true,
                showHeader: true,
                showBtn: false,     //不显示下拉按钮
                delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
                idField: "id",
                keyField: "title",
                clearable: true
            });

            //网点名称
            $("#remainMan2").bsSuggest('enable')
            catbs.on('onSetSelectValue', function (e, keyword, data) {
                $('#jxs_queding2').find('.inin').html(keyword.key)
                $('#jxs_queding2').show()
                $('#jxs_input2').hide()
                $('#jxs_input2').find('input').val(keyword.id)


                //产品名称
                $("#categoryName").bsSuggest('destroy')
                $("#categoryName").bsSuggest({
//                url: "{:url('select/product')}?keyword="+keyword.id,
                    url: "{:url('select/product')}",
                    effectiveFieldsAlias:{title: "名称"},
                    ignorecase: true,
                    showHeader: true,
                    showBtn: false,     //不显示下拉按钮
                    delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
                    idField: "id",
                    keyField: "title",
                    clearable: true
                }).on('onSetSelectValue', function (e, keyword, data) {
                    $(this).val('')
                    var bool = false
                    $('#renyuan2 .ren').each(function (idx,o) {
                        if($(this).data('id') == keyword.id){
                            bool = true;
                        }
                    })
                    if(bool == false){
                        $('#renyuan2').append('<span class="ren" data-id="'+keyword.id+'">'+keyword.key+'<span class="close">×</span></span>')

                        var jxs_id = $('#remainMan').val()
                        var net_id = $('#remainMan2').val()

                        //ajax搜索产品相关信息
                        $.post('{:url("search_product_by_id")}',{id:keyword.id,jxs_id:jxs_id,net_id:net_id},function (data) {
                            $('#table1 tbody').append(data)
                        })

                    }
                });
                $("#categoryName").bsSuggest('enable')
            });
        }).on('onUnsetSelectValue', function () {
            console.log("onUnsetSelectValue");
        });

        //关闭经销商选择
        $('#jxs_queding .close').click(function () {
            $(this).closest('#jxs_queding').hide().find('.inin').html('')
            $('#jxs_input').show().find('input').val('')

        })

        //弹出经销商树
        $('#select').click(function () {
            layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("TiApply2/selectJXS")}'
            })
            return  false
        })

        })
 </script>
<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
function xiugai(did){
    var index = layer.open({
                            type:2,
                            title:'修改数据',
                            area:['100%','100%'],
                            maxmin:true,
                            content:'{:url("xiugai")}?did='+did
                        })
}
function shanchu(did){
    var num=0;
     $(".ckde").each(function(){
        num++;
    })
     if(num>1){
          $.post("{:url('shanchu')}",{did:did,aid:$("#addData").attr("aid")},function(re){
           if(re==1){
                  swal({
                    title: "成功",
                    text:  "操作已完成",
                    type: "success"
                    },function(){
                        location.href="{:url('TiApply/addform')}?aid="+$("#addData").attr("aid");
                    });
           }else{
               swal({
                    title: "错误",
                    text:  "您没有选择要删除的明细",
                    type: "warning"
                    });
           }
        })
     }else{
         swal({
                    title: "错误",
                    text:  "至少保留一条明细",
                    type: "warning"
                    });
     }
}
$(".plsc").click(function(){
    var flag=0;
    var num=0;
    var dids=[];
     $(".ckde").each(function(){
        if($(this).prop("checked")){
             dids[flag]=$(this).val();
            flag++;

        }
        num++;
    })
     if(flag==num){
        swal({
                    title: "错误",
                    text:  "至少保留一条明细",
                    type: "warning"
                    });
     }else if(flag==0){
        swal({
                    title: "错误",
                    text:  "您没有选择要删除的明细",
                    type: "warning"
                    });
     }else{
        var str=dids.join(',');
        $.post("{:url('shanchu')}",{did:str,aid:$("#addData").attr("aid")},function(re){
           if(re==1){
                  swal({
                    title: "成功",
                    text:  "操作已完成",
                    type: "success"
                    },function(){
                        location.href="{:url('TiApply/addform')}?aid="+$("#addData").attr("aid");
                    });
           }else{
               swal({
                    title: "错误",
                    text:  "您没有选择要删除的明细",
                    type: "warning"
                    });
           }
        })
     }

})
$(".fx").click(function(){
    $(".ckde").each(function(){
        if($(this).prop("checked")){
            $(this).prop("checked",false);
        }else{
            $(this).prop("checked",true);
        }
    })
})
 $(".qx").click(function(){
       
        $(".ckde").prop("checked",true);
        
    })
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [{if condition="$aid neq 0"} value="{$apply.annex_id}" {/if}];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

        $('#renyuan').on('click','.ren .close',function () {
            $(this).closest('.ren').remove()
        })
    });
   

</script>
   
</body>

</html>